//
//  LeftModelCell.m
//  Parson
//
//  Created by lanou3g on 16/5/4.
//  Copyright © 2016年 Mango. All rights reserved.
//

#import "LeftModelCell.h"
#import "LeftModel.h"
#import "UIImageView+WebCache.h"
#import "UIView+Extension.h"

@interface LeftModelCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *catReadnumLabel;
@end

@implementation LeftModelCell

- (void)setModel:(LeftModel *)model {
    if (_model != model) {
        _model = model;
    }
    
    NSString *oriStr = model.pic;
    NSArray *urlArr = [oriStr componentsSeparatedByString:@"!"];

    
    [_iconView sd_setImageWithURL:[NSURL URLWithString:urlArr[0]]placeholderImage:[UIImage imageNamed:@"placeholder"]];
    _titleLabel.text = model.title;
    _catReadnumLabel.text = [NSString stringWithFormat:@"%@   阅读%ld",model.cat[@"name"],model.readnum];
    
}



- (void)awakeFromNib {
    self.iconView.contentMode = UIViewContentModeScaleAspectFill;
    self.iconView.clipsToBounds = YES;
}

- (void)setFrame:(CGRect)frame {
    frame.origin.y += 8;
    frame.size.height -= 8;
    [super setFrame:frame];
}


#pragma mark 切换至日间模式
-(void)updateToDaySkinMode {
    self.titleLabel.textColor = [UIColor blackColor];
    self.catReadnumLabel.textColor = [UIColor blackColor];
    self.contentView.backgroundColor = [UIColor whiteColor];
}

#pragma mark 切换至夜间模式
-(void)updateToNightSkinMode {
    self.titleLabel.textColor = [UIColor grayColor];
    self.catReadnumLabel.textColor = [UIColor grayColor];
    self.contentView.backgroundColor = [UIColor colorWithRed:42/255.0 green:39/255.0 blue:43/255.0 alpha:1.0];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
